package com.tang.portal.controller.admin.log;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tang.framework.core.controller.BaseController;
import com.tang.framework.core.domain.HttpResult;
import com.tang.log.domain.AdminSuccessLog;
import com.tang.log.model.req.ReqLogSearch;
import com.tang.log.model.res.RequestResponseTimeLine;
import com.tang.log.model.res.RequestStatistics;
import com.tang.portal.facade.admin.log.RequestLogFacade;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * @Author tang jun liang
 * @Date 2023/5/20 22:28
 */
@RestController
@Tag(name = "请求日志")
@RequestMapping("/request/log")
public class RequestLogController extends BaseController {

    @Resource
    private RequestLogFacade requestLogFacade;


    @Operation(summary = "统计")
    @PostMapping("/statistics")
    public HttpResult<RequestStatistics> statistics() {
        return requestLogFacade.statistics();
    }

    @Operation(summary = "响应时间")
    @PostMapping("/responseTimeLine")
    public HttpResult<List<RequestResponseTimeLine>> responseTimeLine(){
        return requestLogFacade.responseTimeLine();
    }


    @Operation(summary = "管理后台请求成功的日志")
    @PostMapping(value = "/admin/success")
    public HttpResult<Page<AdminSuccessLog>> adminSuccessLogList(@RequestBody ReqLogSearch logSearch) {
        return ok(requestLogFacade.adminSuccessLogList(logSearch));
    }


}
